package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.util.ExpandCodeEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserIntegralBalanceAddRequest extends Request {

	/**
	 * 其它方式添加积分
	 */
	private static final long serialVersionUID = 1930551498585505591L;

	
	private Integer userId ;
	
	private Integer point ;
	
	private Integer type ;
	//expandCode 渠道
	private String expandCode ;
	//remark说明，登记积分来源明细
	private String remark;
	
	private Integer applicablePlatformId;
	
	public Integer getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(Integer applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}

	public String getExpandCode() {
		return expandCode;
	}

	public void setExpandCode(String expandCode) {
		this.expandCode = expandCode;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	public Integer getPoint() {
		return point;
	}

	public void setPoint(Integer point) {
		this.point = point;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.point = requestInfo.getIntParameter(ApiUrlParamEnum.point.getParamName(), 0);
		this.type = requestInfo.getIntParameter(ApiUrlParamEnum.type.getParamName(), 0);
		this.expandCode = requestInfo.getParameter(ApiUrlParamEnum.expandCode.getParamName(), ExpandCodeEnum.ALL.getId());
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName(), ApplicablePlatformEnum.ALL.getId());
		this.remark = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.remark.getParamName(), ""));
		if (userId < 1) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if (point == null || point == 0 ) {
			throw new RequestIllegalException("error point: " + point);
		}
	}
}
